package com.example.finalapplication;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

public class MineActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mine);
        Intent intent3 = getIntent();
      ViewPager2 viewPager = findViewById(R.id.viewPage2);
      MyPageAdapter pageAdapter = new MyPageAdapter(this);
      viewPager.setAdapter(pageAdapter);

    }
     @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (item.getItemId() == R.id.meun_Xuqin) {
            open_Xuqin();
        }else if(item.getItemId() == R.id.meun_Fruits)
        {
           open_fruit() ;}
        else if(item.getItemId() == R.id.meun_Qiyou){
            open_Qiyou();
        }
        return super.onOptionsItemSelected(item);
    }

    private void open_Xuqin() {
        Intent config4 = new Intent(this, XuqinActivity.class);
        startActivity(config4);
    }
   private void open_fruit() { Intent config5 = new Intent(this, FruitsActivity.class);
     startActivity(config5);
    }
     private void open_Qiyou() {
        Intent config6 = new Intent(this, QiyouActivity.class);
        startActivity(config6);
    }
}